//package com.usian.behavior.listener;
//
//import com.alibaba.fastjson.JSON;
//import com.usian.behavior.service.ApFollowBehaviorService;
//import com.usian.model.behavior.dtos.FollowBehaviorDto;
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.stereotype.Component;
//
//import java.util.Optional;
//
//@Component
//public class FollowBehaviorListener {
//
//    @Autowired
//    private ApFollowBehaviorService apFollowBehaviorService;
//
//    @KafkaListener(topics = "follow.behavior.topic")
//    public void getMsg(ConsumerRecord<?,?> record){
//        Optional<? extends ConsumerRecord<?, ?>> optional = Optional.ofNullable(record);
//        if(optional.isPresent()){
//            Object value = record.value(); //从队列拿到的消息值   object
//            FollowBehaviorDto followBehaviorDto = JSON.parseObject(value.toString(), FollowBehaviorDto.class);
//
//            //调用保存用户行为实体的方法
//            apFollowBehaviorService.saveFollowBehavior(followBehaviorDto);
//            System.out.println("=========================记录用户关注行为成功=============================");
//        }
//    }
//}
